New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UDPSession and Listener should not close conns they did not create #165
Comments
By the way, an easy workaround:
|
Eudi4H
pushed a commit
to Eudi4H/kcp-go
that referenced
this issue
Mar 18, 2020
Eudi4H
pushed a commit
to Eudi4H/kcp-go
that referenced
this issue
Mar 18, 2020
Eudi4H
changed the title
UDPSession should not close conn if it did not create it
UDPSession and Listener should not close conns they did not create
Mar 18, 2020
While working on pull request #167 I realized that the same consideration applies to |
xtaci
pushed a commit
that referenced
this issue
Mar 18, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
DialWithOptions
creates anet.PacketConn
for you.NewConn
,NewConn2
, andNewConn3
allow you to provide your ownnet.PacketConn
. In either case,Close
closes both theUDPSession
and thenet.PacketConn
.https://github.com/xtaci/kcp-go/blob/v5.5.9/sess.go#L373
I think that
Close
should not close thenet.PacketConn
if it was provided by the caller inNewConn
,NewConn2
, orNewConn3
.Compare with quic-go, which has a
createdPacketConn
boolean flag.DialAddr
(equivalent ofDialWithOptions
) sets it to true.Dial
(equivalent ofNewConn2
) sets it to false.Close
closes thenet.PacketConn
only if thecreatedPacketConn
flag is true.https://github.com/lucas-clemente/quic-go/blob/v0.14.4/client.go#L21-L23
https://github.com/lucas-clemente/quic-go/blob/v0.14.4/client.go#L278-L281
https://github.com/lucas-clemente/quic-go/blob/v0.14.4/packet_handler_map.go#L190
Here is a sample program.
go.mod
The output is
I expected the output
The text was updated successfully, but these errors were encountered: